|
1
|
|
|
/** |
|
2
|
|
|
* gulpfile.js for php-library developement |
|
3
|
|
|
* |
|
4
|
|
|
* 1. install node.js & npm |
|
5
|
|
|
* 2. $ npm install |
|
6
|
|
|
* 3. $ gulp server |
|
7
|
|
|
* 4. open http://localhost:9001/ (livereload enabled) |
|
8
|
|
|
* 5. coding on src/*.php and tests/*.php |
|
9
|
|
|
* |
|
10
|
|
|
* enjoy! |
|
11
|
|
|
* |
|
12
|
|
|
* @license https://creativecommons.org/publicdomain/zero/1.0/ CC0-1.0 (No Rights Reserved.) |
|
13
|
|
|
* @link https://github.com/spindle/spindle-lib-template |
|
14
|
|
|
*/ |
|
15
|
|
|
var gulp = require('gulp'); |
|
16
|
|
|
var exec = require('child_process').exec; |
|
17
|
|
|
var connect = require('gulp-connect'); |
|
18
|
|
|
|
|
19
|
|
|
gulp.task('default', ['test', 'inspect']); |
|
20
|
|
|
|
|
21
|
|
|
gulp.task('help', function(){ |
|
22
|
|
|
console.log('gulp test\t... kick vendor/bin/phpunit command'); |
|
|
|
|
|
|
23
|
|
|
console.log('gulp inspect\t... kick vendor/bin/apigen and vendor/bin/pdepend'); |
|
24
|
|
|
console.log('gulp server\t... start static web server on http://localhost:9001/'); |
|
25
|
|
|
console.log('\tcoverage report... http://localhost:9001/coverage/'); |
|
26
|
|
|
console.log('\tApiGen document... http://localhost:9001/api/'); |
|
27
|
|
|
}); |
|
28
|
|
|
|
|
29
|
|
|
gulp.task('test', function(done){ |
|
30
|
|
|
exec('vendor/bin/phpunit --colors=always', function(err, stdout, stderr){ |
|
31
|
|
|
console.log(stdout); |
|
|
|
|
|
|
32
|
|
|
console.error(stderr); |
|
33
|
|
|
done(); |
|
34
|
|
|
}); |
|
35
|
|
|
}); |
|
36
|
|
|
|
|
37
|
|
|
gulp.task('inspect', function(done){ |
|
38
|
|
|
var i = 0, count = function(){ if (++i > 1) done() }; |
|
|
|
|
|
|
39
|
|
|
exec([ |
|
40
|
|
|
'vendor/bin/pdepend', |
|
41
|
|
|
'--jdepend-chart=builds/pdepend.svg', |
|
42
|
|
|
'--overview-pyramid=builds/pyramid.svg', |
|
43
|
|
|
'--summary-xml=builds/summary.xml', |
|
44
|
|
|
'src/'].join(' '), count); |
|
45
|
|
|
exec('vendor/bin/apigen.php', count); |
|
46
|
|
|
}); |
|
47
|
|
|
|
|
48
|
|
|
gulp.task('connect', ['default'], function(){ |
|
49
|
|
|
connect.server({ |
|
50
|
|
|
root: [__dirname + '/builds/'], |
|
|
|
|
|
|
51
|
|
|
port: 9001, |
|
52
|
|
|
livereload: true |
|
53
|
|
|
}); |
|
54
|
|
|
}); |
|
55
|
|
|
|
|
56
|
|
|
gulp.task('reload', ['test'], function(){ |
|
57
|
|
|
return gulp.src('builds/coverage/**') |
|
58
|
|
|
.pipe(connect.reload()); |
|
59
|
|
|
}); |
|
60
|
|
|
|
|
61
|
|
|
gulp.task('server', ['connect'], function(){ |
|
62
|
|
|
gulp.watch(['src/**', 'tests/**'], ['reload']); |
|
63
|
|
|
}); |
|
64
|
|
|
|
|
65
|
|
|
|